const mongoose = require("mongoose");
const moment = require("moment-timezone");
// 创建商品留言集合规则
const goodsCommentsSchema = new mongoose.Schema({
    // 修改时间
    modify: {
        type: String,
        default: moment().tz("Asia/Shanghai").format("YYYY/MM/DD HH:mm:ss"),
    },
    // 商品的id
    sid: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "Goods",
        required: [true, "商品id不能为空"],
    },
    // 留言内容
    content: {
        type: String,
        required: [true, "商品留言内容不能为空"],
    },
    // 是否可见
    display: {
        type: Boolean,
        default: true
    },
    // 评论的用户id
    uid: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "User",
        required: [true, "评论的用户id不能为空"],
    },
});
// 创建商品留言集合
const GoodsComments = mongoose.model("GoodsComments", goodsCommentsSchema);
// 将商品留言集合进行导出
module.exports = GoodsComments;